﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web.UC
{
    public partial class UCAlert : System.Web.UI.UserControl
    {
        public string ContentControlID
        {
            get
            {
                return Convert.ToString(ViewState["ContentControlID"]);
            }
            set
            {
                ViewState["ContentControlID"] = value;
            }
        }
        public string FocusContronID
        {
            get
            {
                return Convert.ToString(ViewState["FocusContronID"]);
            }
            set
            {
                ViewState["FocusContronID"] = value;
            }
        }
        public string Msg {
            set { this.popuTipMsg.Text = value; }
        }
        public Unit Width
        {
            set { this.popuTip.Width = value; }
        }
        public void Show()
        {
           this.popuTip.ShowOnPageLoad=true;
           this.popuTipOk.Focus();
        }
        public void Show(string focusControlID)
        {
            this.FocusContronID = focusControlID;
            this.popuTip.ShowOnPageLoad = true;
            this.popuTipOk.Focus();
        }
        public void Show(string contentControlID,string focusControlID)
        {
            this.ContentControlID = contentControlID;
            this.FocusContronID = focusControlID;
            this.popuTip.ShowOnPageLoad = true;
            this.popuTipOk.Focus();
        }
        public void Hide()
        {
            this.popuTip.ShowOnPageLoad = false;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void popuTipOk_Click(object sender, EventArgs e)
        {            
            this.popuTip.ShowOnPageLoad = false;
            if (this.FocusContronID != "")
            {
                if (this.ContentControlID == "")
                {
                    this.Page.FindControl(this.FocusContronID).Focus();
                }
                else
                {
                    this.Page.FindControl(this.ContentControlID).FindControl(this.FocusContronID).Focus();
                }
            }
        }
    }
}